//
//  HEDoctorMainInfoCell.m
//  HealthFamily
//
//  Created by 吴欧 on 2020/11/17.
//  Copyright © 2020 honglutec. All rights reserved.
//

#import "HEDoctorMainInfoCell.h"

@interface HEDoctorMainInfoCell ()

@property (nonatomic, strong) UIImageView *goodsimgView;
@property (nonatomic, strong) UILabel *titleLb;
@property (nonatomic, strong) UILabel *deptLb;
@property (nonatomic, strong) UILabel *hospLb;

@end

@implementation HEDoctorMainInfoCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self initUI];
    }
    return self;
}

- (void)initUI {
    UIView *warp = [UIView new];
    [self.contentView addSubview:warp];

    [warp mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).mas_offset(0);
        make.left.equalTo(self.contentView).mas_offset(0);
        make.right.equalTo(self.contentView).mas_offset(0);
        make.bottom.equalTo(self.contentView).mas_offset(0);
    }];
    
    // 头像
    _goodsimgView = [UIImageView new];
    _goodsimgView.image = IMAGE_NAMED(@"noImage");
    _goodsimgView.contentMode = UIViewContentModeScaleAspectFill;
    [warp addSubview:_goodsimgView];
    

    // 姓名
    _titleLb = [UILabel new];
    _titleLb.text = @"张三";
    _titleLb.font = DYBlodFont(18);
    [warp addSubview:_titleLb];
    
    // 科室
    _deptLb = [UILabel new];
    _deptLb.text = @"副主任医师 | 老年病科";
    _deptLb.font = DYFont(15);
    _deptLb.textColor = CNavLightBlackColor;
    [warp addSubview:_deptLb];

    // 所属医院
    _hospLb = [UILabel new];
    _hospLb.text = @"中南大学湘雅医院";
    _hospLb.font = DYFont(16);
    _hospLb.textColor = CNavLightBlackColor;
    [warp addSubview:_hospLb];
    
    
    [_goodsimgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(warp).mas_offset(15);
        make.left.equalTo(warp).mas_offset(15);
        make.width.height.mas_offset(90);
        make.bottom.equalTo(warp.mas_bottom).mas_offset(-10);
    }];
    [_goodsimgView hg_setAllCornerWithCornerRadius: 45];
    
    [_titleLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_goodsimgView.mas_top);
        make.left.equalTo(_goodsimgView.mas_right).mas_offset(11);
        make.right.equalTo(warp.mas_right).mas_offset(-10);
    }];

    [_deptLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(_goodsimgView);
        make.left.equalTo(_titleLb.mas_left);
        make.right.equalTo(warp.mas_right).mas_offset(-10);
    }];
  
    [_hospLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(_goodsimgView.mas_bottom);
        make.left.equalTo(_titleLb.mas_left);
        make.right.equalTo(warp.mas_right).mas_offset(-10);
    }];
}

- (void)setModel:(HEDoctorInfoModel *)model {
    _model = model;
    
    [_goodsimgView sd_setImageWithURL:[NSURL URLWithString: model.avatar] placeholderImage: IMAGE_NAMED(@"hmang")];
    
    _titleLb.text =  model.realname;
    _deptLb.text = model.KDeptStr;
    _hospLb.text = model.hospital_name;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
